package org.example.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 定时任务分表切面
 *
 * @Author : Nico
 * @create 2025/3/19 16:34
 */
@Aspect
@Component
@Slf4j
public class ShardingForScheduleAspect {
    @Pointcut("@annotation(ShardingForSchedule)")
    public void cut() {
    }

    @Around("cut()")
    public void around(ProceedingJoinPoint joinPoint) {
        log.info("切面拦截到定时任务分表");
        try {
            joinPoint.proceed();
            joinPoint.proceed();
        } catch (Throwable e) {
            log.error("切面拦截到定时任务分表异常", e);
        }
        log.info("切面拦截到定时任务分表结束");
    }

}
